package cn.nange.cmfz.service.impl;

import cn.nange.cmfz.dao.GuruDao;
import cn.nange.cmfz.entity.Guru;
import cn.nange.cmfz.service.GuruService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class GuruServiceImpl implements GuruService {
    @Autowired
    private GuruDao guruDao;

    @Override
    public void add(Guru g) {
guruDao.insert(g);
    }

    @Override
    public void update(Guru g) {
guruDao.update(g);
    }

    @Override
    public void delete(Integer id) {
guruDao.delete(id);
    }

    @Override
    public void ban(Integer id, Integer status) {
guruDao.ban(id,status);
    }

    @Override
    public Guru showOne(Integer id) {
        return guruDao.selectOne(id);
    }

    @Override
    public List<Guru> showAll() {
        return guruDao.selectAll();
    }

    @Override
    public PageInfo<Guru> showAllPage(int page, int rows) {
        PageHelper.startPage(page, rows);
        PageInfo<Guru> pageInfo = new PageInfo<>(guruDao.selectAll());
        return pageInfo;
    }
}
